package org.lecric.wind44.client.widget;

import java.util.HashMap;

import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.Widget;

public class CachedFrame extends DeckPanel
{
	private HashMap<String, Integer> urls=new HashMap<String, Integer>();

	private String currentUrl;
	private int index=0;

	public void setUrl(String url)
	{
		if(!urls.containsKey(url))
		{
			Frame frame = new Frame();
			frame.setUrl(url);
			add(frame);
			urls.put(url, index++);
		}
		showWidget(urls.get(url));
		currentUrl=url;
	}
	
	public void setWidget(Widget w)
	{
		add(w);
		showWidget(index++);
	}
	
	public void reload()
	{
		urls.clear();
		setUrl(currentUrl);
	}
}
